package com.hp.his.basic.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.hp.his.basic.entity.ExamDetail;
import com.hp.his.basic.entity.ExamSummary;
import com.hp.his.basic.entity.Favorite;
import com.hp.his.core.orm.hibernate.HibernateDao;

@Repository
public class ExamDao extends HibernateDao<ExamDetail, Long>{
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public List<ExamSummary> getExamListByUserId(Integer creatorId){
		//定义查询语句
		String hql = "from ExamSummary where creatorId="+creatorId;
		Query query = getSession().createQuery(hql);
		
		List list = query.list();
		
		return list;
	}
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public List<Favorite> getFavoriteListByUserId(Integer userId){
		//定义查询语句
		String hql = "from Favorite where user.userId="+userId;
		Query query = getSession().createQuery(hql);
		
		List list = query.list();
		
		return list;
	}
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public ExamDetail getExamById(Integer examId){
		//定义查询语句
		String hql = "from ExamDetail where examId="+examId;
		Query query = getSession().createQuery(hql);
		
		List list = query.list();
		
		return (ExamDetail)list.get(0);
	}
	
	
}
